#!/sbin/openrc-run
supervisor=supervise-daemon
description="Visualize and manage your ElasticSearch data"
name="Kibana"

: ${command_user:="kibana"}
: ${command_group:="$(id -gn $user)"}
: ${logs_dir:="/var/log/kibana"}
: ${work_dir:="/var/tmp/kibana"}
: ${conf_file:="/etc/kibana/kibana.yml"}

pidfile="/run/kibana/$RC_SVCNAME.pid"
supervise_daemon_args="-u $command_user -g $command_group -p $pidfile"
command=/usr/share/webapps/kibana/bin/kibana
command_args="--config $conf_file 1>>$logs_dir/kibana.log 2>>$logs_dir/error.log"

export BABEL_CACHE_PATH=/var/tmp/kibana/.babelcache.json

depends() {
        use net
	after firewall
}

start_pre() {
	for dir in \
		"$logs_dir" \
		"$work_dir" \
		"${pidfile%/kibana.pid}" \
		; do checkpath -d -o $command_user:$command_group -m755 $dir
	done
}
